package trace

import (
	"gin-study/config"
	"github.com/opentracing/opentracing-go"
	"github.com/uber/jaeger-client-go"
	"github.com/uber/jaeger-client-go/transport"
	"io"
)

func NewTracer() (opentracing.Tracer, io.Closer) {
	sender := transport.NewHTTPTransport(
		config.Services.TraceEndpoint,
	)
	tracer, closer := jaeger.NewTracer(
		config.App.Name,
		jaeger.NewConstSampler(true),
		jaeger.NewRemoteReporter(sender),
	)
	return tracer, closer
}
